
[#include "single/layout/layout02/layout.ftl"/]
[@htmlHead]
[/@htmlHead]
[@htmlBody]

<div class="row ">
    <div class="col-xs-12">
        <ul class="nav nav-tabs">
            <li>
                <a href="${base}/organization/view/index">机构列表</a>
            </li>

            [#if "add"==operateType]
                <li class="active">
                    <a> 机构增加 </a>
                </li>
            [#else ]
                <li class="active">
                    <a> 机构编辑 </a>
                </li>
            [/#if]

        </ul>

</div>
    <div class="row">
        <form class="form-horizontal" action="${base}/organization/view/update" method="post" id="editForm">
            <input name="id" type="hidden" value="${organization.id}">

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label "><span class="required">*</span>归属机构</label>

                <div class="col-xs-10 col-sm-4  ">
                    <div class="input-group input-large">
                          [#if org??]
                              <input id="orgText" name="orgText" value="${org.name}" placeholder="" readonly
                                     class="form-control "/>
                           <span class="input-group-btn" onclick="component.org.choose('选择机构','orgId','orgText')">
                                <button type="button" class="btn  blue"><i class="fa fa-search"></i></button>
                            </span>
                              <input id="orgId" name="parentId" value="${org.parentId}" type="hidden"/>
                              [#else]
                                  <input id="orgText" value="--顶级--" placeholder="" readonly
                                         class="form-control "/>
                           <span class="input-group-btn" onclick="component.org.choose('选择机构','orgId','orgText')">
                                <button type="button" class="btn  blue"><i class="fa fa-search"></i></button>
                            </span>
                                  <input id="orgId" name="parentId" value="-1" type="hidden"/>
                          [/#if]


                  </div>
               </div>
            </div>


            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label"><span class="required">*</span>归属区域</label>
                <div class="col-xs-10 col-sm-4  ">
                    <div class="input-group input-large">
                        <input id="areaName" name="areaName" value="${area.name}" placeholder="" readonly
                               class="form-control "/>
                         <span class="input-group-btn" onclick="component.area.choose('选择地区','areaId','areaName')">
                                <button type="button" class="btn  blue"><i class="fa fa-search"></i></button>
                            </span>
                        <input id="areaId" name="areaId" value="${area.id}" type="hidden"/>
                        </div>
                </div>

            </div>


            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label "><span class="required">*</span>机构名称</label>

                <div class="col-xs-10 col-sm-4  ">
                    <input name="name" value="${organization.name}" placeholder="请输入机构名称"
                           class="form-control input-large"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label "><span class="required">*</span>机构编码</label>

                <div class="col-xs-10 col-sm-4  ">
                    <input name="code" value="${organization.code}" placeholder="请输入编码4位数字"
                           class="form-control input-large" maxlength="4"/>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">排序</label>

                <div class="col-xs-10 col-sm-4  ">
                    <input name="sort" value="${organization.sort}" placeholder="排序"
                           class="form-control input-large"/>
                </div>
            </div>

            <div class="form-group">
                <div id="editAlert" class="" style="min-width:550px"></div>
                <label class="col-xs-10 col-sm-4 control-label ">机构类型</label>

                <div class="col-xs-10 col-sm-4  ">
                    <select name="type" class="form-control input-small">
                        [#if orgType?exists]
                            [#list orgType as type]
                                [#if type.key==organization.type]
                                    <option value="${type.key}" selected>${type.value}</option>
                                [#else ]
                                    <option value="${type.key}">${type.value}</option>
                                [/#if]
                            [/#list]
                        [/#if]
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">机构级别</label>

                <div class="col-xs-10 col-sm-4  ">
                    <select name="grade" class="form-control input-small">
                        [#if orgGrade?exists]
                            [#list orgGrade as grade]
                                [#if grade.key==organization.grade]
                                    <option value="${grade.key}" selected>${grade.value}</option>
                                [#else ]
                                    <option value="${grade.key}">${grade.value}</option>
                                [/#if]
                            [/#list]
                        [/#if]
                    </select>
                </div>
            </div>

            <div class="form-group">

                <label class="col-xs-10 col-sm-4 control-label ">是否启用</label>

                <div class="col-xs-10 col-sm-4  ">
                    <div class="btn-group" role="group">
                        [#if organization.isEnabled=='0']
                            <button  class="btn btn-sm" type="button" value="1">开启</button>
                            <button  class="btn btn-success btn-sm" type="button" value="0">禁用</button>
                            <input type="hidden" name="isEnabled" value="0"/>
                        [#else]
                            <button  class="btn btn-success btn-sm" type="button" value="1">开启</button>
                            <button  class="btn btn-sm" type="button" value="0">禁用</button>
                            <input type="hidden" name="isEnabled" value="1"/>
                        [/#if]
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">主负责人</label>

                <div class="col-xs-10 col-sm-4  ">
                    <div class="input-group input-large">
                        <input id="userText1" name="userText1" value="${primaryUser.name}" placeholder="" readonly
                               class="form-control "/>
                       <span class="input-group-btn" onclick="component.user.choose('主负责人','userId1','userText1')">
                                <button type="button" class="btn  blue"><i class="fa fa-search"></i></button>
                            </span>
                        <input id="userId1" name="primaryPersonId" value="${organization.primaryPersonId}" type="hidden"/>

                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">副负责人</label>


                <div class="col-xs-10 col-sm-4  ">
                    <div class="input-group input-large">
                        <input id="userText2" name="userText2" value="${deputyUser.name}" placeholder="" readonly
                               class="form-control "/>
                       <span class="input-group-btn" onclick="component.user.choose('副负责人','userId2','userText2')">
                                <button type="button" class="btn  blue"><i class="fa fa-search"></i></button>
                            </span>
                        <input id="userId2" name="deputyPersonId" value="${organization.deputyPersonId}" type="hidden"/>

                    </div>
                </div>

            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">联系地址</label>

                <div id="choiceIcon" class="col-xs-10 col-sm-4  ">
                    <input name="address" value="${organization.address}" placeholder=""
                           class="form-control input-large"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">邮政编码</label>

                <div id="choiceIcon" class="col-xs-10 col-sm-4  ">
                    <input name="zipCode" value="${organization.zipCode}" placeholder=""
                           class="form-control input-large"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">负责人</label>
                <div class="col-xs-10 col-sm-4  ">
                <div class="input-group input-large">
                    <input id="userText3" name="userText3" value="${deputyUser.name}" placeholder="" readonly
                           class="form-control "/>
                       <span class="input-group-btn" onclick="component.user.choose('负责人','userId3','userText3')">
                                <button type="button" class="btn  blue"><i class="fa fa-search"></i></button>
                            </span>
                    <input id="userId3" name="deputyPersonId" value="${organization.deputyPersonId}" type="hidden"/>
                 </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">电话</label>

                <div id="choiceIcon" class="col-xs-10 col-sm-4  ">
                    <input name="phone" value="${organization.phone}" placeholder="" class="form-control input-large"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">传真</label>

                <div id="choiceIcon" class="col-xs-10 col-sm-4  ">
                    <input name="fax" value="${organization.fax}" placeholder="" class="form-control input-large"/>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">邮箱</label>

                <div id="choiceIcon" class="col-xs-10 col-sm-4  ">
                    <input name="email" value="${organization.email}" placeholder="" class="form-control input-large"/>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-10 col-sm-4 control-label ">备注信息</label>

                <div class="col-xs-10 col-sm-4  ">
                    <textarea name="description" class="form-control input-large">${organization.description}</textarea>
                </div>
            </div>

            <div class="form-group">
                <label class=" col-xs-10 col-sm-4  control-label"></label>
                <div class="col-xs-10 col-sm-4 " align="center">
                    <input type="button" class="btn btn-info btn-sm" value="确定" onclick="doSubmit('${operateType}')"/>
                    <input type="button" onclick="tools.goto('${base}/organization/view/index')" class="btn btn-cancle btn-sm" value="返回"/>
                </div>
            </div>
        </form>
    </div>
</div>
[/@htmlBody]
[@htmlFoot]
    [#include "common/validate.ftl"/]
<script src="${jpath}/assets/public/plugins/dialog/bootbox.js" type="text/javascript"></script>
<script src="${base}/plugins/single/js/module/organization/organization.js" type="text/javascript"></script>


<script type="text/javascript">
    $(function () {

    })
    if (typeof component == "undefined" || typeof component.area == "undefined") {
        if (typeof component == "undefined") {
            var component = {"area": {}};
        } else {
            component.area = {};
        }
        component.area.choose = function (title, idField, textField) {
            var url = base + "/area/view/toTreeList?idField=" + idField + "&textField=" + textField;
            var buttons = {
                btnOk: {
                    label: '确定',
                    callback: function () {
                    }
                },
                btnCancel: {
                    label: '取消',
                    callback: function () {
                    }
                }
            }
            $.messager.dialog({url: url, title: title, buttons: {}, iframe: {width: 368, height: 450}});
        }
    }

    if(typeof component == "undefined"||typeof component.user =="undefined"){
        if(typeof component == "undefined"){
            var component={"user":{}};
        }else{
            component.user={};
        }
        component.user.choose=function (title,idField,textField){
            var url=base+"/organization/view/toUserList?idField="+idField+"&textField="+textField;
            var buttons={
                btnOk: {
                    label: '确定',
                    callback: function() {
                    }
                },
                btnCancel:{
                    label: '取消',
                    callback: function() {
                    }
                }
            }
            $.messager.dialog({url: url, title: title, buttons: {},iframe:{width:600,height:450}});
        }
    }
    if(typeof component == "undefined"||typeof component.org =="undefined"){
        if(typeof component == "undefined"){
            var component={"org":{}};
        }else{
            component.org={};
        }
        component.org.choose=function (title,idField,textField,companyId){
            var url=base+"/organization/view/toTreeList?idField="+idField+"&textField="+textField+"&id="+companyId;
            var buttons={
                btnOk: {
                    label: '确定',
                    callback: function() {
                    }
                },
                btnCancel:{
                    label: '取消',
                    callback: function() {
                    }
                }
            };
            $.messager.dialog({url: url, title: title, buttons: {},iframe:{width:368,height:450}});
        }
    }
</script>
[/@htmlFoot]